﻿using Microsoft.EntityFrameworkCore.Migrations;

namespace YunDrug.Migrations
{
    public partial class initv12 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_App_机构信息_App_机构类别_机构类别编码",
                table: "App_机构信息");

            migrationBuilder.DropForeignKey(
                name: "FK_App_字典项_App_字典信息_字典信息编码",
                table: "App_字典项");

            migrationBuilder.DropPrimaryKey(
                name: "PK_App_字典信息",
                table: "App_字典信息");

            migrationBuilder.DropPrimaryKey(
                name: "PK_App_字典项",
                table: "App_字典项");

            migrationBuilder.DropPrimaryKey(
                name: "PK_App_机构信息",
                table: "App_机构信息");

            migrationBuilder.DropPrimaryKey(
                name: "PK_App_机构类别",
                table: "App_机构类别");

            migrationBuilder.RenameTable(
                name: "App_字典信息",
                newName: "Drug_字典信息");

            migrationBuilder.RenameTable(
                name: "App_字典项",
                newName: "Drug_字典项");

            migrationBuilder.RenameTable(
                name: "App_机构信息",
                newName: "Drug_机构信息");

            migrationBuilder.RenameTable(
                name: "App_机构类别",
                newName: "Drug_机构类别");

            migrationBuilder.RenameIndex(
                name: "IX_App_字典项_字典信息编码",
                table: "Drug_字典项",
                newName: "IX_Drug_字典项_字典信息编码");

            migrationBuilder.RenameIndex(
                name: "IX_App_机构信息_机构类别编码",
                table: "Drug_机构信息",
                newName: "IX_Drug_机构信息_机构类别编码");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Drug_字典信息",
                table: "Drug_字典信息",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Drug_字典项",
                table: "Drug_字典项",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Drug_机构信息",
                table: "Drug_机构信息",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Drug_机构类别",
                table: "Drug_机构类别",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_Drug_机构信息_Drug_机构类别_机构类别编码",
                table: "Drug_机构信息",
                column: "机构类别编码",
                principalTable: "Drug_机构类别",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Drug_字典项_Drug_字典信息_字典信息编码",
                table: "Drug_字典项",
                column: "字典信息编码",
                principalTable: "Drug_字典信息",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Drug_机构信息_Drug_机构类别_机构类别编码",
                table: "Drug_机构信息");

            migrationBuilder.DropForeignKey(
                name: "FK_Drug_字典项_Drug_字典信息_字典信息编码",
                table: "Drug_字典项");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Drug_字典信息",
                table: "Drug_字典信息");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Drug_字典项",
                table: "Drug_字典项");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Drug_机构信息",
                table: "Drug_机构信息");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Drug_机构类别",
                table: "Drug_机构类别");

            migrationBuilder.RenameTable(
                name: "Drug_字典信息",
                newName: "App_字典信息");

            migrationBuilder.RenameTable(
                name: "Drug_字典项",
                newName: "App_字典项");

            migrationBuilder.RenameTable(
                name: "Drug_机构信息",
                newName: "App_机构信息");

            migrationBuilder.RenameTable(
                name: "Drug_机构类别",
                newName: "App_机构类别");

            migrationBuilder.RenameIndex(
                name: "IX_Drug_字典项_字典信息编码",
                table: "App_字典项",
                newName: "IX_App_字典项_字典信息编码");

            migrationBuilder.RenameIndex(
                name: "IX_Drug_机构信息_机构类别编码",
                table: "App_机构信息",
                newName: "IX_App_机构信息_机构类别编码");

            migrationBuilder.AddPrimaryKey(
                name: "PK_App_字典信息",
                table: "App_字典信息",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_App_字典项",
                table: "App_字典项",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_App_机构信息",
                table: "App_机构信息",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_App_机构类别",
                table: "App_机构类别",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_App_机构信息_App_机构类别_机构类别编码",
                table: "App_机构信息",
                column: "机构类别编码",
                principalTable: "App_机构类别",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_App_字典项_App_字典信息_字典信息编码",
                table: "App_字典项",
                column: "字典信息编码",
                principalTable: "App_字典信息",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
